

import 'dart:convert';

import 'package:containerbox_study/Untils/TestApi.dart';
import 'package:containerbox_study/Untils/encrypt_untils.dart';
import 'package:containerbox_study/routers/router_table.dart';
import 'package:containerbox_study/schema/theme.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';

import 'package:encrypt/encrypt.dart';
import 'package:flutter/services.dart';
import 'package:pointycastle/asymmetric/api.dart';


class ThemePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
      child: Container(
      width: 150,
      height: 50,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(4.0),
        color: Colors.blue,
      ),
      child: TextButton(
        onPressed: (){
          // RouterManager.router!.navigateTo(context, RouterManager.loginPath);
          // Navigator.of(context).pushNamed(RouterTable.loginPath);
          // login();
          // getUserInfo();
          getThemeTop();
        },
        child: Text('登陆', style: TextStyle(color: Colors.white),)),
      ),
      ),
      );
  }

   void login() async {
    Dio dio = Dio();
    Response response;
    Map<String, String> params = {'mobile' : '18516574564', 'password' : '123456'};
    print('参数 - ${json.encode(params)}');

  String encrypted = await EncryptUntils.encodeString(json.encode(params));
  print(encrypted);
    // EncryptUntils.initRsa('enpty/rsa/publish.pem');
    // String dataStr = EncryptUntils.encryptRsa(json.encode(params));
    // print('dataStr = $dataStr');
    Map <String, dynamic> data = {'data' : encrypted};
    response = await dio.post(
      'https://lhapi.laohucaijing.com/lh-api/api/member/laohuapi/ioslogin', 
      queryParameters: data);
    print('得到的结果 response = $response.data.toString');
  }


  
  void getUserInfo() async{
    var responseStr = await LaoHuAPI.getUserInfo();
    print(responseStr);
  }

  void getThemeTop() async {
    List themeModels = await LaoHuAPI.getThemeRealTopList();
    ThemeModel model = themeModels.first;
    print(model.title);
  }

}


